package leetcode_2501_2600;

import java.util.Set;
import java.util.TreeSet;

public class LeeCode_2506 {
    public static void main(String[] args) {

    }
    private static int similarPairs(String[] words) {
        int n = words.length;
        String[] p = new String[n];
        TreeSet<Character> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < words[i].length(); j++) {
                set.add(words[i].charAt(j));
            }
            StringBuilder sb = new StringBuilder();
            for (Character c : set) {
                sb.append(c);
            }
            p[i] = sb.toString();
            set.removeAll(set);
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (p[i].equals(p[j])){
                    ans++;
                }
            }
        }
        return ans;
    }
}
